// pages/detail/detail.js
const musicDetail = require("../../models/musicDetail")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    value:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (options) {
    console.log(options.id);
    var res = await musicDetail(options.id);
    this.setData({
      value:res.data.playlist
    })
    console.log(this.data.value);
  },
  onChange(event){
    var value = this.data.value;
    value.tracks.forEach(res=>{
      if(res.id == event.currentTarget.dataset.id){
        res.state = !res.state;
      }else{
        res.state = false
      }
    });
    this.setData({
      value
    });
  }
})